/*
               File: C36
        Description: Conversion for table MMCRE10
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 18 de Junio de 2010 12:37:35.30
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class c36 extends GXProcedure
{
   public c36( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( c36.class ), "" );
   }

   public c36( int remoteHandle ,
               ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor C362 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A300LCreUU = C362_A300LCreUU[0] ;
         A299LCreHU = C362_A299LCreHU[0] ;
         A298LCreFU = C362_A298LCreFU[0] ;
         A297LCreUC = C362_A297LCreUC[0] ;
         A296LCreHC = C362_A296LCreHC[0] ;
         A295LCreFC = C362_A295LCreFC[0] ;
         A294LCreEs = C362_A294LCreEs[0] ;
         A293LCreSa = C362_A293LCreSa[0] ;
         A292LCreMt = C362_A292LCreMt[0] ;
         A291LCreCo = C362_A291LCreCo[0] ;
         A35PrsCod = C362_A35PrsCod[0] ;
         /*
            INSERT RECORD ON TABLE GXA0036

         */
         AV2PrsCod = A35PrsCod ;
         AV3CliCod = 0 ;
         AV4LCreCod = A291LCreCo ;
         if ( C362_n292LCreMt[0] )
         {
            AV5LCreMto = 0 ;
         }
         else
         {
            AV5LCreMto = A292LCreMt ;
         }
         if ( C362_n293LCreSa[0] )
         {
            AV6LCreSal = 0 ;
         }
         else
         {
            AV6LCreSal = A293LCreSa ;
         }
         if ( C362_n294LCreEs[0] )
         {
            AV7LCreEst = "" ;
         }
         else
         {
            AV7LCreEst = A294LCreEs ;
         }
         if ( C362_n295LCreFC[0] )
         {
            AV8LCreFCR = GXutil.nullDate() ;
         }
         else
         {
            AV8LCreFCR = A295LCreFC ;
         }
         if ( C362_n296LCreHC[0] )
         {
            AV9LCreHCR = "" ;
         }
         else
         {
            AV9LCreHCR = A296LCreHC ;
         }
         if ( C362_n297LCreUC[0] )
         {
            AV10LCreUC = "" ;
         }
         else
         {
            AV10LCreUC = A297LCreUC ;
         }
         if ( C362_n298LCreFU[0] )
         {
            AV11LCreFU = GXutil.nullDate() ;
         }
         else
         {
            AV11LCreFU = A298LCreFU ;
         }
         if ( C362_n299LCreHU[0] )
         {
            AV12LCreHU = "" ;
         }
         else
         {
            AV12LCreHU = A299LCreHU ;
         }
         if ( C362_n300LCreUU[0] )
         {
            AV13LCreUU = "" ;
         }
         else
         {
            AV13LCreUU = A300LCreUU ;
         }
         /* Using cursor C363 */
         pr_default.execute(1, new Object[] {AV2PrsCod, new Short(AV3CliCod), new Short(AV4LCreCod), new Double(AV5LCreMto), new Double(AV6LCreSal), AV7LCreEst, AV8LCreFCR, AV9LCreHCR, AV10LCreUC, AV11LCreFU, AV12LCreHU, AV13LCreUU});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         /* End Insert */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      C362_A300LCreUU = new String[] {""} ;
      C362_A299LCreHU = new String[] {""} ;
      C362_A298LCreFU = new java.util.Date[] {GXutil.nullDate()} ;
      C362_A297LCreUC = new String[] {""} ;
      C362_A296LCreHC = new String[] {""} ;
      C362_A295LCreFC = new java.util.Date[] {GXutil.nullDate()} ;
      C362_A294LCreEs = new String[] {""} ;
      C362_A293LCreSa = new double[1] ;
      C362_A292LCreMt = new double[1] ;
      C362_A291LCreCo = new short[1] ;
      C362_A35PrsCod = new String[] {""} ;
      A300LCreUU = "" ;
      A299LCreHU = "" ;
      A298LCreFU = GXutil.nullDate() ;
      A297LCreUC = "" ;
      A296LCreHC = "" ;
      A295LCreFC = GXutil.nullDate() ;
      A294LCreEs = "" ;
      A293LCreSa = 0 ;
      A292LCreMt = 0 ;
      A291LCreCo = 0 ;
      A35PrsCod = "" ;
      GIGXA0036 = 0 ;
      AV2PrsCod = "" ;
      AV3CliCod = 0 ;
      AV4LCreCod = 0 ;
      C362_n292LCreMt = new boolean[] {false} ;
      AV5LCreMto = 0 ;
      C362_n293LCreSa = new boolean[] {false} ;
      AV6LCreSal = 0 ;
      C362_n294LCreEs = new boolean[] {false} ;
      AV7LCreEst = "" ;
      C362_n295LCreFC = new boolean[] {false} ;
      AV8LCreFCR = GXutil.nullDate() ;
      C362_n296LCreHC = new boolean[] {false} ;
      AV9LCreHCR = "" ;
      C362_n297LCreUC = new boolean[] {false} ;
      AV10LCreUC = "" ;
      C362_n298LCreFU = new boolean[] {false} ;
      AV11LCreFU = GXutil.nullDate() ;
      C362_n299LCreHU = new boolean[] {false} ;
      AV12LCreHU = "" ;
      C362_n300LCreUU = new boolean[] {false} ;
      AV13LCreUU = "" ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new c36__default(),
         new Object[] {
             new Object[] {
            C362_A300LCreUU, C362_n300LCreUU, C362_A299LCreHU, C362_n299LCreHU, C362_A298LCreFU, C362_n298LCreFU, C362_A297LCreUC, C362_n297LCreUC, C362_A296LCreHC, C362_n296LCreHC,
            C362_A295LCreFC, C362_n295LCreFC, C362_A294LCreEs, C362_n294LCreEs, C362_A293LCreSa, C362_n293LCreSa, C362_A292LCreMt, C362_n292LCreMt, C362_A291LCreCo, C362_A35PrsCod
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short A291LCreCo ;
   private short AV3CliCod ;
   private short AV4LCreCod ;
   private short Gx_err ;
   private int GIGXA0036 ;
   private double A293LCreSa ;
   private double A292LCreMt ;
   private double AV5LCreMto ;
   private double AV6LCreSal ;
   private String A300LCreUU ;
   private String A299LCreHU ;
   private String A297LCreUC ;
   private String A296LCreHC ;
   private String A294LCreEs ;
   private String A35PrsCod ;
   private String AV2PrsCod ;
   private String AV7LCreEst ;
   private String AV9LCreHCR ;
   private String AV10LCreUC ;
   private String AV12LCreHU ;
   private String AV13LCreUU ;
   private String Gx_emsg ;
   private java.util.Date A298LCreFU ;
   private java.util.Date A295LCreFC ;
   private java.util.Date AV8LCreFCR ;
   private java.util.Date AV11LCreFU ;
   private IDataStoreProvider pr_default ;
   private String[] C362_A300LCreUU ;
   private String[] C362_A299LCreHU ;
   private java.util.Date[] C362_A298LCreFU ;
   private String[] C362_A297LCreUC ;
   private String[] C362_A296LCreHC ;
   private java.util.Date[] C362_A295LCreFC ;
   private String[] C362_A294LCreEs ;
   private double[] C362_A293LCreSa ;
   private double[] C362_A292LCreMt ;
   private short[] C362_A291LCreCo ;
   private String[] C362_A35PrsCod ;
   private boolean[] C362_n292LCreMt ;
   private boolean[] C362_n293LCreSa ;
   private boolean[] C362_n294LCreEs ;
   private boolean[] C362_n295LCreFC ;
   private boolean[] C362_n296LCreHC ;
   private boolean[] C362_n297LCreUC ;
   private boolean[] C362_n298LCreFU ;
   private boolean[] C362_n299LCreHU ;
   private boolean[] C362_n300LCreUU ;
}

final class c36__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("C362", "SELECT [LCreUUM], [LCreHUM], [LCreFUM], [LCreUCR], [LCreHCR], [LCreFCR], [LCreEst], [LCreSal], [LCreMto], [LCreCod], [PrsCod] FROM [MMCRE10] WITH (NOLOCK) ORDER BY [PrsCod], [LCreCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("C363", "INSERT INTO [GXA0036] ([PrsCod], [CliCod], [LCreCod], [LCreMto], [LCreSal], [LCreEst], [LCreFCR], [LCreHCR], [LCreUCR], [LCreFUM], [LCreHUM], [LCreUUM]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((String[]) buf[2])[0] = rslt.getString(2, 8) ;
               ((boolean[]) buf[3])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[4])[0] = rslt.getGXDate(3) ;
               ((boolean[]) buf[5])[0] = rslt.wasNull();
               ((String[]) buf[6])[0] = rslt.getString(4, 10) ;
               ((boolean[]) buf[7])[0] = rslt.wasNull();
               ((String[]) buf[8])[0] = rslt.getString(5, 8) ;
               ((boolean[]) buf[9])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[10])[0] = rslt.getGXDate(6) ;
               ((boolean[]) buf[11])[0] = rslt.wasNull();
               ((String[]) buf[12])[0] = rslt.getString(7, 1) ;
               ((boolean[]) buf[13])[0] = rslt.wasNull();
               ((double[]) buf[14])[0] = rslt.getDouble(8) ;
               ((boolean[]) buf[15])[0] = rslt.wasNull();
               ((double[]) buf[16])[0] = rslt.getDouble(9) ;
               ((boolean[]) buf[17])[0] = rslt.wasNull();
               ((short[]) buf[18])[0] = rslt.getShort(10) ;
               ((String[]) buf[19])[0] = rslt.getString(11, 10) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setShort(2, ((Short) parms[1]).shortValue());
               stmt.setShort(3, ((Short) parms[2]).shortValue());
               stmt.setDouble(4, ((Double) parms[3]).doubleValue());
               stmt.setDouble(5, ((Double) parms[4]).doubleValue());
               stmt.setString(6, (String)parms[5], 1);
               stmt.setDate(7, (java.util.Date)parms[6]);
               stmt.setString(8, (String)parms[7], 8);
               stmt.setString(9, (String)parms[8], 10);
               stmt.setDate(10, (java.util.Date)parms[9]);
               stmt.setString(11, (String)parms[10], 8);
               stmt.setString(12, (String)parms[11], 10);
               break;
      }
   }

}

